package roborally.Commands;

import roborally.*;

/**
 * A class of Turn-commands for playing the roborally game.
 * 
 * @version  2.90
 * @author   Michiel Ruelens & Dieter Naten
 */
public class Turn extends Command {
	
	private Rotation rotation;
	
	/**
	 * Create a new turn command with the given rotation (Rotation.Clockwise or Rotation.Anticlockwise).
	 */
	public Turn(Rotation rotation){
		this.setStringForm("turn");
		this.rotation = rotation;
	}

	/**
	 * Makes the robot turn if it has sufficient energy.
	 */
	@Override
	public void execute(Robot robot) {
		if(robot.getEnergy()>=robot.getCostToTurn()){
			if(rotation == Rotation.Clockwise){
				robot.turnClockwise();
			}
			else{
				robot.turnAntiClockwise();
			}
		}
		else{
			System.out.println("Nothing executed because of insufficient energy to shoot.");
		}		
	}

}
